﻿
@{
    ViewData["Title"] = "设备管理";
    Layout = "~/Views/Shared/_Layout_Content.cshtml";
}


@section styles
    {
    <environment names="Development">
        <link href="~/css/plugins/jqgrid/ui.jqgrid.css" rel="stylesheet" />
    </environment>
    <environment names="Staging,Production">
        <link rel="stylesheet" href="~/css/grid.min.css" asp-append-version="true" />
    </environment>
    <link href="~/js/plugins/select2/css/select2.css" rel="stylesheet" />
    <link href="~/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
}

<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5></h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
        
                <div class="form-group">
                    <button id="btnAdd" type="button" class="btn btn-primary " onclick="addModel()"><i class="fa fa-check"></i>&nbsp;添加</button>
                    <button id="btnEdit" type="button" class="btn btn-info " onclick="editModel()"><i class="fa fa-paste"></i> 编辑</button>
                    <button id="btnDel" type="button" class="btn btn-danger " onclick="delData()">
                        <i class="fa fa-dedent"></i>&nbsp;&nbsp;<span class="bold">删除</span>
                    </button>
                    @*<input type="file" onchange="doUpload()" id="excelfile" name="excelfile" class="btn btn-info" value="Excel上传" />*@
                </div>
                <div class="form-group">
                    @*<div class="row">
                    <div class="col-md-3">
                        <div class="col-sm-8">
                            <div class='input-group date' id='OpenDate'>
                                <input type='text' id='OpenCycle' name="OpenCycle" class="form-control" />
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                        </div>

                    </div>
                    <div class="col-md-3">
                        <select name="Devicess" id="Devicess" class="form-control" placeholder="设备" multiple="multiple"></select>
                    </div>
                    <div class="col-md-3">
                        <select name="Workerss" id="Workerss" class="form-control" placeholder="员工" multiple="multiple"></select>
                    </div>
                </div>*@
                    <div class="row p5 m5">
                        <div class="col-md-2">
                            <input id="txtSearchKey" type="text" class="input form-control" placeholder="群组名称" />
                        </div>
                        <div class="col-md-2">
                            <span class="input-group-btn">
                                <button id="btnSearch" class="btn btn btn-primary" type="button"> <i class="fa fa-search"></i> 搜索</button>
                            </span>
                        </div>
                    </div>


                </div>

                <div class="jqGrid_wrapper">
                    <table id="table_list"></table>
                    <div id="pager_list"></div>
                </div>
        </div>
    </div>
</div>

@section scripts
    {
        <script src="~/js/plugins/jqgrid/jquery.jqGrid.js"></script>
        <script src="~/js/plugins/jqgrid/i18n/grid.locale-cn.js"></script>
        <script src="~/js/jqgrid-list.js"></script>
        <script src="~/js/json2.js"></script>
        <script src="~/js/base.js"></script>
        <script src="~/js/moment.js"></script>
        <script src="~/js/bootstrap-datetimepicker.min.js"></script>
    <environment names="Staging,Production">
        <script src="~/js/grid.min.js" asp-append-version="true"></script>
        <script src="~/js/validate.min.js" asp-append-version="true"></script>
        <script src="~/js/base.min.js" asp-append-version="true"></script>
    </environment>
    <script src="~/js/plugins/select2/js/select2.js"></script>
    <script src="~/js/BindSelect.js"></script>
    <script>
        $("#OpenCycles").select2();
        BindSelect("Devicess", "/HardWare/GetHardWares");
        BindSelect("Workerss", "/Worker/GetWorkers");
        function addModel() {
            $("#btnAdd").button("loading");
            window.location.href = "@Url.Action("Add")";
        }
        $(function () {
            $('#OpenDate').datetimepicker({
                format: 'YYYY-MM-DD',
                locale: moment.locale('zh-cn')
            });
        });
        function editModel() { //编辑
            var row = JucheapGrid.GetData();
            if (row != null) {
                $("#btnEdit").button("loading");
                window.location.href = "@Url.Action("Edit")/" + row.id;
            } else {
                alert("请选择要编辑的数据");
            }
        }
        //function doUpload() {
        //    var formData = new FormData($("#uploadForm")[0]);
        //    $.ajax({
        //        url: "/Xlsx/ImportGroup",
        //        //beforeSend: function (xhr) {
        //        //    xhr.setRequestHeader("XSRF-TOKEN",
        //        //        $('input:hidden[name="__RequestVerificationToken"]').val());
        //        //},
        //        type: 'POST',
        //        data: formData,
        //        async: false,
        //        cache: false,
        //        contentType: false,
        //        processData: false,
        //        success: function (returndata) {
        //            alert("上传成功");
        //            //$("#imgUserHeadImageUrl").attr('src', '/upload/' + returndata);
        //            //$("#IdentificationHeadImageUrl").val(returndata);
        //        },
        //        error: function (returndata) {
        //        }
        //    });
        //}
        function delData() { //删除
            XPage.DelData("@Url.Action("Delete")");
        }

        function searchData() { //搜索
            var json = {
                //OpenCycle: $("#OpenCycle").val(),
                //DevicesId: $("#DevicesId").val(),
                //WorkersId: $("#WorkersId").val(),
                name: $("#txtSearchKey").val(),
            };
            XPage.Search(json);
        }

        $(document).ready(function() {
           var config = {
                title: '列表',
                url: '@Url.Action("GetListWithPager")',
               colNames: ['序号','组id', '群组名称', '开放周期', ],
                colModel: [
                    { name: 'id', index: 'id', width: 60, key: true, hidden: true },
                    { name: 'id', index: 'id', width: 60},
                    { name: 'name', index: 'name', width: 60 },
                    { name: 'openCycle', index: 'openCycle', width: 60 },
                ]
            };
            JucheapGrid.Load(config);
            $("#btnSearch").bind("click", searchData);

        });
    </script>
}


